/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ADT;

import Interfaces.BoundingBox;
import Interfaces.Container;
import Interfaces.Mass;
import Interfaces.Pallet;
import Interfaces.Stowage;
import Interfaces.StowageLocation;
import java.util.Collection;
import java.util.Set;

/**
 *
 * @author markusbaisch
 */
public class ContainerImpl extends BodyImpl implements Container {

    final Mass empty;
    final Mass max;
    StowageLocation loc;
    Stowage<Pallet> palletStowage;

    // Konstruktor
    private ContainerImpl( Mass mass, Mass empty, Mass max, BoundingBox box) {
        if( mass.kg() > max.kg() ) throw new IllegalArgumentException("Container zu schwer!");
        this.mass = mass;
        this.empty = empty;
        this.max = max;
        this.boundingBox = box;
    }

    static Container valueOf(Mass mass, Mass empty, Mass max, BoundingBox box) {
        return new ContainerImpl(mass, empty, max, box);
    }
    
    @Override
    public Mass emptyMass() {
        return empty;
    }

    @Override
    public Mass maxMass() {
        return max;
    }

    @Override
    public boolean isEmpty() {
        return palletStowage.isEmpty();
    }

    @Override
    public boolean isFull() {
        return palletStowage.isFull();
    }

    @Override
    public void load(int bayNo, int rowNo, Pallet elem) {
        palletStowage.load(bayNo, rowNo, elem);
    }

    @Override
    public void load(Pallet elem) {
        palletStowage.load(elem);
    }

    @Override
    public void loadAll(Collection<? extends Pallet> coll) {
        palletStowage.loadAll( coll );
    }

    @Override
    public boolean tierIsEmpty(int bayNo, int rowNo) {
        return palletStowage.tierIsEmpty(bayNo, rowNo);
    }

    @Override
    public boolean tierIsFull(int bayNo, int rowNo) {
        return palletStowage.tierIsFull(bayNo, rowNo);
    }

    @Override
    public boolean contains(Object elem) {
        return palletStowage.contains(elem);
    }

    @Override
    public boolean containsAll(Collection<?> coll) {
        return palletStowage.containsAll(coll);
    }

    @Override
    public Pallet get(StowageLocation loc) {
        return palletStowage.get(loc);
    }

    @Override
    public Set<Pallet> getAll() {
        return palletStowage.getAll();
    }

    @Override
    public StowageLocation locationOf(Pallet elem) {
        return palletStowage.locationOf(elem);
    }

    @Override
    public StowageLocation loc() {
        return loc;
    }

    @Override
    public void setLocNull() {
        loc = Entities.nullLocation();
    }

    @Override
    public void setLoc(Object stowage, StowageLocation loc) {
        this.loc = loc;
        if(stowage instanceof Stowage) this.palletStowage = (Stowage)stowage;
    }

    @Override
    public boolean isFree() {
        return false;
    }

    @Override
    public boolean isBlocked() {
        return false;
    }

    @Override
    public boolean isOccupied() {
        return true;
    }

    @Override
    public int compareTo(Container t) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
